import Vue from 'vue';
import { remote } from '@/api/admin/dict';
import zhLocale from './lang/zh';
// 获取环境变量配置
export const getEnvConfig = (async () => {
  try {
    const { data } = await remote('environment_config');
    const configData = data.data || [];
    const configObj = {};
    configData.forEach((el) => {
      configObj[el.label] = el.value;
    });
    Vue.prototype.$configObj = configObj;

    // console.log(configObj);

    const { AK, SK, bucket, scope, url } = configObj;
    // eslint-disable-next-line no-undef
    Vue.use(AVUE, {
      qiniu: {
        AK, // 七牛云相关密钥
        SK, // 七牛云相关密钥
        bucket, // 七牛云地址
        scope, // 存储空间名称
        url, // 外链的域名地址
      },
    });
    // eslint-disable-next-line no-undef
    Vue.use(AVUE, {
      locale: zhLocale,
      size: 'small',
      menuType: 'text',
    });
  } catch (error) {
    throw new Error(error);
  }
})();
